package cn.edu.ecnu.gis.client.gadgets;

import cn.edu.ecnu.gis.client.MashupGISEntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;

import cn.edu.ecnu.gis.client.Th3CallService;
import cn.edu.ecnu.gis.client.Th3CallServiceAsync;
import cn.edu.ecnu.gis.client.model.Gadget;
import cn.edu.ecnu.gis.client.model.GadgetClass;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.ImageBundle;
import com.google.gwt.user.client.ui.ListBox;

public class ChartWidget extends Gadget {

    public static interface OperationIcon extends ImageBundle {

//        public AbstractImagePrototype addLineIcon();
//
//        public AbstractImagePrototype addPolygonIcon();
//
//        public AbstractImagePrototype addPointIcon();
//
//        public AbstractImagePrototype zoomInIcon();
//
//        public AbstractImagePrototype zoomOutIcon();
    }
    public static OperationIcon operationIcon = (OperationIcon) GWT.create(OperationIcon.class);

    public static class Class extends GadgetClass {

        public Class() {
            super("地图编辑", false);
            this.setGadgetType(2);
        }

        public Gadget newGadget() {
            return new ChartWidget(this);
        }
    }
    private HorizontalPanel outPanel = new HorizontalPanel();
    private HorizontalPanel paraPanel = new HorizontalPanel();
    private HorizontalPanel chPanel = new HorizontalPanel();
    private ListBox chtlb = new ListBox();

    protected ChartWidget(Class c) {
        super(c);
        initWidget(outPanel);
        paraPanel.add(chtlb);


    // Create an asynchronous callback to handle the result.

    }
    final AsyncCallback callback = new AsyncCallback() {

        public void onSuccess(Object result) {
            //   wsreturn.setText((String) result);
        }

        public void onFailure(Throwable caught) {
            //  wsreturn.setText("Communication failed");
        }
    };

    public static Th3CallServiceAsync getService() {
        // Create the client proxy. Note that although you are creating the
        // service interface proper, you cast the result to the asynchronous
        // version of
        // the interface. The cast is always safe because the generated proxy
        // implements the asynchronous interface automatically.
        Th3CallServiceAsync service = (Th3CallServiceAsync) GWT.create(Th3CallService.class);
        // Specify the URL at which our service implementation is running.
        // Note that the target URL must reside on the same domain and port from
        // which the host page was served.
        //
        ServiceDefTarget endpoint = (ServiceDefTarget) service;
        String moduleRelativeURL = GWT.getModuleBaseURL() + "th3callservice";
        endpoint.setServiceEntryPoint(moduleRelativeURL);
        return service;
    }

    public interface BoundImage extends ImageBundle {

        AbstractImagePrototype inbox();
    }

    public AbstractImagePrototype getBoundImage() {
        BoundImage images = (BoundImage) GWT.create(BoundImage.class);
        return images.inbox();
    }
}
